$(function(){
			//关闭底部下载app
			$('.dow-close').click(function(){
				$('#bottom-download').hide();
			})

			
			//左侧列表效果	
			// $('.list-box-left').hide();
			$('.list-box-right').each(function(){
				$(this).hover(function() {
					$(this).css({
						'background':'#b28247'
					})
					$(this).find('i').css({
						'color':'#fff'
					})
					$(this).find('span').css({'display':'inline-block'});
				}, function() {
					$(this).css({
						'background':'#333',
					})
					$(this).find('i').css({
						'color':'#b28247'
					})
					$(this).find('span').hide();
				});	
			})
			
			//表单事件
			var day=1;
		if ($('#remeber').prop('checked') == true) {
			day = 10;
		}
		 $("#enrollForm").validate({
				rules:{
					phone:{
						required:true,
						phone:true
					},
					num:{
						required:true,
						checknum:true
					},
					password:{
						required:true,
						minlength:6,
						maxlength:20,
						password:true 
					},
					repassword:{
						required:true,
						repassword:true
					}
				},
				messages:{
					phone:{
						required:'请输入手机号码',
						phone:'号码格式不符合'
					},
					num:{
						required:'请输入手机验证码',
						checknum:'验证码错误'
					},
					password:{
						required:'请输入密码',
						password:'密码格式不对'
					},
					repassword:{
						required:'请再次输入密码',
						repassword:'密码不一致'
					}
				},
				submitHandler:function() {
					alert('注册成功');
					test();
				}
			});
	 		//将验证码放进cookie里面，30分钟后过期
	 		$('.checknum').click(function(){
	 			var expiresDate= new Date();
					expiresDate.setTime(expiresDate.getTime() + (30 * 60 * 1000));
	 			var str="";
			 	for (var i = 0; i < 4; i++) {
			 	   	var n = parseInt(Math.random()*9+1);
			 	  	str +=n;
				}
				console.log(str);
				$('.checknum').text(str);
				$.cookie('checknum', str,{expires:expiresDate,path:'/'}); 
	 		})
 			
 			jQuery.validator.addMethod("phone", function(value, element) {  
			    var length = value.length;  
			    var regPhone = /^1([3578]\d|4[57])\d{8}$/;  
			    return this.optional(element) || ( length == 11 && regPhone.test( value ) );    
			}, "请正确填写您的手机号码"); 

			jQuery.validator.addMethod("checknum", function(value, element) {  
				var num = $.cookie('checknum');
			    return this.optional(element) || ( value == num ); 
			}, "验证码错误");  

			jQuery.validator.addMethod("password", function(value, element) {  
			    var regPass = /((?=.*\d)(?=.*\D)|(?=.*[a-zA-Z])(?=.*[^a-zA-Z]))^.{8,16}$/;  
			    return this.optional(element) || (  regPass.test( value ) );    
			}, "请正确填写您密码"); 

			jQuery.validator.addMethod("repassword", function(value, element) { 
				var again = $('#password').val();  
			    return this.optional(element) || ( again == value);    
			}, "请重复填写您密码");
				
			//确定后返回到cookie	
			function test(){
				var username = $('#phone').val();
						var password = $('#password').val();
						var str = '[{"username":"'+username+'","password":"'+ password +'"}]'
						$.cookie(username,str,{expires:day,path:'/'});
						window.location.href="login.html";	
			}							
})	